package 牛客.搜狐.线程;

import javax.xml.transform.OutputKeys;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args){
        Object obj = new Object();
//        List obj = new ArrayList();
        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (obj){
                    for(int i =1;i<53;i++){
                        System.out.print(i);
                        if (i%2==0){
                            obj.notifyAll();
                            if (i!=52) {
                                try {
                                    obj.wait();
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }

                }
            }
        });
        Thread thread2 = new Thread(()->{
            synchronized (obj){
                for (int i = 65;i<65+26;i++){
                    char cq = (char) i;
                    System.out.print(cq+" ");
                    obj.notifyAll();
                    if (cq!='Z') {
                        try {
                            obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        });
        thread1.start();
        thread2.start();
    }
}
